﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Fitness.Data;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace Fitness.VariableTemplate
{
    public class VariableTiles:DataTemplateSelector
    {
        public DataTemplate TipTemplate { get; set; }
        public DataTemplate ServiceSmallTemplate { get; set; }
        public DataTemplate ServiceLargeTemplate { get; set; }
        public DataTemplate CalculatorsTemplate { get; set; }
        public DataTemplate LatestTemplate { get; set; }
        public DataTemplate RecipesBigTemplate { get; set; }
        public DataTemplate RecipesSmallTemplate { get; set; }
        public DataTemplate RecipesMediumTemplate { get; set; }
        public DataTemplate RecipesLagreTemplate { get; set; }
        public DataTemplate SuccessTemplate { get; set; }


 protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
        {
            FrameworkElement element = container as FrameworkElement;

            if (element != null && item != null)
            {

                if (item.GetType() == typeof(HubPageDataItem))
                {

                   if ((item as HubPageDataItem).UniqueId.StartsWith("Tip"))
                        return TipTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("ServiceSmall"))
                        return ServiceSmallTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("SLT"))
                        return ServiceLargeTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("Calculators"))
                        return CalculatorsTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("Latest"))
                        return LatestTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("RecipesBig"))
                        return RecipesBigTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("RecipesSmall"))
                        return RecipesSmallTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("RecipesMedium"))
                        return RecipesMediumTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("RecipesLagre"))
                        return RecipesLagreTemplate;
                    if ((item as HubPageDataItem).UniqueId.StartsWith("Success"))
                        return SuccessTemplate;
                   }



                else if (item.GetType() == typeof(RecipesPageDataItem))
                {
                    if ((item as RecipesPageDataItem).UniqueId.StartsWith("Tip"))
                        return TipTemplate;
                    if ((item as RecipesPageDataItem).UniqueId.StartsWith("ServiceSmall"))
                        return ServiceSmallTemplate;
                    if ((item as RecipesPageDataItem).UniqueId.StartsWith("SLT"))
                        return ServiceLargeTemplate;
                    if ((item as RecipesPageDataItem).UniqueId.StartsWith("Calculators"))
                        return CalculatorsTemplate;
                    if ((item as RecipesPageDataItem).UniqueId.StartsWith("Latest"))
                        return LatestTemplate;
                    if ((item as RecipesPageDataItem).UniqueId.StartsWith("RecipesBig"))
                        return RecipesBigTemplate;
                    if ((item as RecipesPageDataItem).UniqueId.StartsWith("RecipesSmall"))
                        return RecipesSmallTemplate;
                    if ((item as RecipesPageDataItem).UniqueId.StartsWith("RecipesMedium"))
                        return RecipesMediumTemplate;
                    if ((item as RecipesPageDataItem).UniqueId.StartsWith("RecipesLagre"))
                        return RecipesLagreTemplate;
                    if ((item as RecipesPageDataItem).UniqueId.StartsWith("Success"))
                        return SuccessTemplate;
                   }
            }
           

            return base.SelectTemplateCore(item, container);
        }

    }
}